/*
 * 版权所有(c)  1952110078@qq.com  2022 - 2022
 */

package com.ldc.module_main.viewmodel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.ldc.commonlibs.common.ViewModelBase;
import com.ldc.commonlibs.http.NetCallback;
import com.ldc.commonlibs.http.RetrofitClient;
import com.ldc.module_main.model.FlowsModel;
import com.ldc.module_main.net.HttpService;

import java.util.HashMap;
import java.util.List;

/**
 * @author liudc
 * @since 2022/7/17 21:22
 */
public class MainViewModel extends ViewModelBase {
    private HttpService apiService = RetrofitClient.getInstance().getService(HttpService.class);
    private MutableLiveData<FlowsModel> _flowsModel = new MutableLiveData<>();

    public LiveData<FlowsModel> getFlowsModel() {
        return _flowsModel;
    }

    public void flows(String uid, int offset) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("uid", uid);
        map.put("offset", offset);
        getNetDataSource(apiService.flows(map), new NetCallback<FlowsModel>() {
            @Override
            public void onReceiver(FlowsModel data) {
                _flowsModel.setValue(data);
            }

            @Override
            public void onBadReceiver(Throwable throwable) {
                _flowsModel.setValue(null);
            }
        });
    }
}
